<!--
 * @Author: lixb
 * @Date: 2020-09-04 10:14:53
 * @LastEditTime: 2020-09-16 18:24:02
 * @Descripttion: 福利分配详情
-->
<template>
  <div>
    <el-card class="title-card">
      <div>
        <span>分配主题：</span>
        {{ titleInfo.grantTheme }}
      </div>
      <div>
        <span>分配人数：</span>
        {{ titleInfo.totalQuantity }}
      </div>
      <div>
        <span>分配总额度：</span>
        {{ titleInfo.paymentAmount }}
      </div>
    </el-card>
    <el-card class="main-card">
      <Table
        :table-data="tableData"
        :prop-data="propData"
        :table-index="true"
        :paging-data="pagingData"
        @getTableList="getTableList"
      >
        <template slot="uagrState">
          <el-table-column prop="uagrState" label="状态">
            <template slot-scope="scope">
              <span>
                {{
                  scope.row.uagrState == 0 ? '待确认' : scope.row.uagrState == 1 ? '成功' : '已取消'
                }}
              </span>
            </template>
          </el-table-column>
        </template>
        <template slot="deptName">
          <el-table-column prop="deptName" label="部门">
            <template slot-scope="scope">
              <span>
                {{
                  (scope.row.uaacOrganizationDept && scope.row.uaacOrganizationDept.deptName) || ''
                }}
              </span>
            </template>
          </el-table-column>
        </template>
      </Table>
    </el-card>
  </div>
</template>
<script>
  import Table from '@/components/Table';
  import {
    listUaacAdvanceGrantRecordDetail,
    listUaacAdvanceGrantRecordDetailTotal,
  } from '@/api/careCard';
  export default {
    components: { Table },
    data() {
      return {
        titleInfo: {
          paymentAmount: '',
          totalQuantity: '',
          grantTheme: '',
        },
        tableData: [],
        propData: [
          {
            prop: 'uuRealName',
            label: '姓名',
          },
          {
            prop: 'deptName',
            label: '部门',
            type: 'deptName',
          },
          {
            prop: 'uuMobilePhone',
            label: '账号',
          },
          {
            prop: 'amount',
            label: '分配额度（元）',
          },
          {
            prop: 'uagrState',
            label: '状态',
            type: 'uagrState',
          },
        ],
        pagingData: {
          total: 10,
          current: 1,
          size: 10,
        },
      };
    },
    activated() {
      this.getTableList();
      this.getTitleInfo();
    },
    methods: {
      getTableList() {
        let params = {
          recordId: this.$route.query.id,
        };
        listUaacAdvanceGrantRecordDetail(params, this.pagingData).then(res => {
          if (res.status == 200) {
            this.tableData = res.data.records;
            this.pagingData.total = res.data.total;
          }
        });
      },
      getTitleInfo() {
        let params = {
          recordId: this.$route.query.id,
        };
        listUaacAdvanceGrantRecordDetailTotal(params).then(res => {
          if (res.status == 200) {
            this.titleInfo = res.data;
          }
        });
      },
    },
  };
</script>
<style lang="scss" scoped>
  .title-card {
    div {
      display: inline-block;
      margin-right: 30px;
      span {
        color: #7f848b;
      }
    }
  }
  .main-card {
    margin-top: 20px;
  }
</style>
